Skip to content

[fix] prototype pollution을 통한 Stored XSS 취약점 차단#3072

Closed
chanlee wants to merge 1 commit into
developfrom
fix/prototype-pollution-xss
Closed

[fix] prototype pollution을 통한 Stored XSS 취약점 차단#3072
chanlee wants to merge 1 commit into
developfrom
fix/prototype-pollution-xss

Conversation

@chanlee

@chanlee chanlee commented May 29, 2026

Copy link
Copy Markdown
Collaborator

배경

유저 제보로 확인된 Stored XSS 취약점입니다. 특정 블록 조합이 포함된 작품을 임의의 사용자가 실행하기만 해도, 작품에 저장된 악성 코드가 prototype pollution을 거쳐 XSS로 실행됩니다.

익스플로잇 체인 (검증 완료)

  1. 근본 원인 — 예약어 필터 우회 (src/playground/scope.js)

    • filterReservedKeywordsSet.has(param)으로 문자열 "__proto__"만 차단.
    • 공격자가 param을 배열 ["__proto__"]로 넣으면 hasfalse → 통과.
    • 이후 객체 키로 쓰이는 순간 JS가 String(["__proto__"]) === "__proto__"로 변환하여 우회.
  2. 오염 게이트 — kkmoo 하드웨어 블록 (src/playground/blocks/hardware/block_KKMOO.js)

    • kkmoo_set_frame_time/kkmoo_set_frame/kkmoo_set_motor_degree에서
      Entry.kkmoo.motionFrame[motnum] 등을 인덱스 검증 없이 사용.
    • motnum이 배열이면 motionFrame["__proto__"]Array.prototype 접근 → Array.prototype.time 오염.
  3. Sink — DOM innerHTML

    • 오염된 Array.prototype.time이 davinci 블록 실행 흐름을 거쳐 모든 배열의 .time으로 노출.
    • time.entity.parent.scene.inputWrapper.innerHTML<img src=x onerror=...> 페이로드가 들어가 Stored XSS 실행.

수정 내용

1. (근본) src/playground/scope.js

filterReservedKeywords에서 param이 객체/배열이면 String()으로 정규화한 뒤 예약어와 비교. 한 곳 수정으로 getParam/getParams/getField 전 경로의 우회를 차단.

  • 차단 키는 __proto__만 유지(호환성 우선). 정상 문자열·숫자·객체 param은 영향 없음.

2. (심층) src/playground/blocks/hardware/block_KKMOO.js

오염 게이트였던 kkmoo 모션 블록 3종에서 motnumNumber()로 강제하고 배열 범위를 검증한 뒤에만 인덱싱. 범위 밖이면 무시.

검증

  • filterReservedKeywords 단위 검증 통과 — "__proto__" / ["__proto__"]"", 정상값은 원본 유지
  • ✅ 수정 파일 node --check 문법 검증 통과
  • ⚠️ jest 스위트는 기존 Babel 플러그인 누락으로 실행 불가(Tests: 0 total) — 본 변경과 무관한 환경 문제

남은 권고

  • 본 PR은 __proto__만 차단(호환성 우선). constructor/prototype 키 변형은 추후 영향도 점검 후 별도 강화 검토 권장.

🤖 Generated with Claude Code

Entry.Scope의 예약어 필터가 문자열 "__proto__"만 차단하여,
배열 ["__proto__"]를 객체 키로 사용할 때 String() 변환으로 우회되는
prototype pollution → Stored XSS 취약점을 수정한다.

- scope.js: filterReservedKeywords에서 객체/배열 param을 정규화 후 검사
- block_KKMOO.js: kkmoo 모션 블록 3종의 motnum 인덱스 범위 검증 추가

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread src/playground/scope.js
Comment on lines +32 to +33
const normalized =
typeof param === 'object' && param !== null ? String(param) : param;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Delete ⏎···········

Suggested change
const normalized =
typeof param === 'object' && param !== null ? String(param) : param;
const normalized = typeof param === 'object' && param !== null ? String(param) : param;

@chanlee

chanlee commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

#3073과 중복되어 close

@chanlee chanlee closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant